package com.ruoyi.web.controller.market.account;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.AccountItemSpecialHis;
import com.ruoyi.account.service.IAccountItemSpecialHisService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.AccountItemSpecialHisWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机构账户流水Controller
 * 
 * @author ruoyi
 * @date 2023-07-28
 */
@Controller
@RequestMapping("/account/itemSpecialHis")
public class AccountItemSpecialHisController extends BaseController
{
    private String prefix = "account/itemSpecialHis";

    @Autowired
    private IAccountItemSpecialHisService accountItemSpecialHisService;

    @RequiresPermissions("account:itemSpecialHis:view")
    @GetMapping("/{accountId}")
    public String itemSpecialHis(@PathVariable("accountId") String accountId, ModelMap mmap)
    {
        mmap.put("accountId", accountId);
        return prefix + "/itemSpecialHis";
    }

    /**
     * 查询机构账户流水列表
     */
    @RequiresPermissions("account:itemSpecialHis:view")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AccountItemSpecialHis accountItemSpecialHis)
    {
        startPage();
        List<Map<String, Object>> mapList = accountItemSpecialHisService.selectAccountItemSpecialHisListMap(accountItemSpecialHis);
        mapList = new AccountItemSpecialHisWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出机构账户流水列表
     */
    @RequiresPermissions("account:itemSpecialHis:export")
    @Log(title = "机构账户流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AccountItemSpecialHis accountItemSpecialHis)
    {
        List<AccountItemSpecialHis> list = accountItemSpecialHisService.selectAccountItemSpecialHisList(accountItemSpecialHis);
        ExcelUtil<AccountItemSpecialHis> util = new ExcelUtil<AccountItemSpecialHis>(AccountItemSpecialHis.class);
        return util.exportExcel(list, "机构账户流水数据");
    }

    /**
     * 新增机构账户流水
     */
    @GetMapping("/add/{accountId}")
    public String add(ModelMap modelMap, @PathVariable("accountId") String accountId)
    {
        modelMap.put("accountId", accountId);
        return prefix + "/add";
    }

    /**
     * 新增保存机构账户流水
     */
    @RequiresPermissions("account:itemSpecialHis:add")
    @Log(title = "机构账户流水", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AccountItemSpecialHis accountItemSpecialHis)
    {
        return toAjax(accountItemSpecialHisService.insertAccountItemSpecialHis(accountItemSpecialHis));
    }

    /**
     * 修改机构账户流水
     */
    @RequiresPermissions("account:itemSpecialHis:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AccountItemSpecialHis accountItemSpecialHis = accountItemSpecialHisService.selectAccountItemSpecialHisById(id);
        mmap.put("accountItemSpecialHis", accountItemSpecialHis);
        return prefix + "/edit";
    }

    /**
     * 修改保存机构账户流水
     */
    @RequiresPermissions("account:itemSpecialHis:edit")
    @Log(title = "机构账户流水", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AccountItemSpecialHis accountItemSpecialHis)
    {
        return toAjax(accountItemSpecialHisService.updateAccountItemSpecialHis(accountItemSpecialHis));
    }

    /**
     * 删除机构账户流水
     */
    @RequiresPermissions("account:itemSpecialHis:remove")
    @Log(title = "机构账户流水", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(accountItemSpecialHisService.deleteAccountItemSpecialHisByIds(ids));
    }
}
